package com.wyg.service.impl;

import com.wyg.dao.TeacherDao;
import com.wyg.datasources.annotation.DataSource;
import com.wyg.entity.Teacher;
import com.wyg.mybatis.enums.SexEnum;
import com.wyg.quartz.util.IdGenerate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService{
    @Autowired
    private TeacherDao teacherDao;

    @DataSource("first")
    @Override
    public List<Teacher> getTeacherList() {
        return teacherDao.getTeacherList();
    }

    @Override
    public int addList() {
        List<Teacher> teachers = new ArrayList<>();
        Teacher t1 = new Teacher();
        Teacher t2 = new Teacher();
        Teacher t3 = new Teacher();
        t1.setId(IdGenerate.generateId());
        t1.setName("张三");
        t1.setAge(23);
        t1.setPhoneNumber("15278965348");
        t1.setSex(SexEnum.MALE);

        t2.setId(IdGenerate.generateId());
        t2.setName("小红");
        t2.setAge(24);
        t2.setPhoneNumber("15913647489");
        t2.setSex(SexEnum.FEMALE);

        t3.setId(IdGenerate.generateId());
        t3.setName("王五");
        t3.setAge(25);
        t3.setPhoneNumber("13178964129");
        t3.setSex(SexEnum.MALE);
        teachers.add(t1);
        teachers.add(t2);
        teachers.add(t3);
        return teacherDao.insert(teachers);
    }
}
